package vo
{
	import control.CardMachine;
	
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLRequest;
	
	public class GameMode
	{
		private var goChannel:SoundChannel;
		private var tuneUp:Sound;
		private var tuneIn:URLRequest;
		
		public var gameCardsVO:GameCardsVO = new GameCardsVO();
		public var cardList:Array;
		public var isEnd:Boolean;
		
		public var chip:int = 0;
		public var winChip:int = 0;		
		public var allChips:int = 100;
		
		public var isWin:Boolean;
		
		public var cardMachine:CardMachine;
		
		private static var instance:GameMode = null;	
		
		public function GameMode()
		{
//			if( instance != null ){			
//				throw new Error (" 单例模型能且紧能实例一次！")			
//			}
			
		}
					
		public function initDate():void{
//			chip = 10;
//			winChip = 0;
//			allChips = 100;
			isWin = false;
			isEnd = false;
			gameCardsVO = new GameCardsVO();
			cardMachine = new CardMachine();
		}
		
		public static function getInstance ():GameMode{			
			return instance ||= new GameMode();
		}
		
		//开始播放
		public function playMe( song:String ):void{
			
			if( goChannel != null ){
				goChannel.stop();
			}
			tuneUp = new Sound;
			tuneIn = new URLRequest(song);
			tuneUp.load(tuneIn);
			goChannel = tuneUp.play();
		}
		
		//停止播放		
		public function stopMe():void{
			if( goChannel != null ){
				goChannel.stop();
			}
		}
	}
}